home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / benchmarks / bcopy / RCS / bcopy.c,v < prev   
Encoding:
Text File  |  1990-03-30  |  2.7 KB  |  130 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     90.03.30.14.45.55;  author ouster;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     89.08.31.13.19.27;  author ouster;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Try 200k transfer size too.
  27. @
  28. text
  29. @/* 
  30.  * bcopy.c --
  31.  *
  32.  *    Benchmark program to measure memory bandwidth.
  33.  *    Invoke with no arguments.  It will make repeated
  34.  *    calls to bcopy with different size buffers and
  35.  *    print memory bandwidth as a function of buffer
  36.  *    size.
  37.  *    
  38.  *
  39.  * Copyright 1989 Regents of the University of California
  40.  * Permission to use, copy, modify, and distribute this
  41.  * software and its documentation for any purpose and without
  42.  * fee is hereby granted, provided that the above copyright
  43.  * notice appear in all copies.  The University of California
  44.  * makes no representations about the suitability of this
  45.  * software for any purpose.  It is provided "as is" without
  46.  * express or implied warranty.
  47.  */
  48.  
  49. #ifndef lint
  50. static char rcsid[] = "$Header: /sprite/src/benchmarks/bcopy/RCS/bcopy.c,v 1.1 89/08/31 13:19:27 ouster Exp Locker: ouster $ SPRITE (Berkeley)";
  51. #endif /* not lint */
  52.  
  53. #include <stdio.h>
  54. #include <sys/time.h>
  55. #include <sys/resource.h>
  56.  
  57. /*
  58.  * Different amounts to copy at once:
  59.  */
  60.  
  61. int sizes[] =
  62.     {10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 200000, -1};
  63.  
  64. #define MAX_AT_ONCE 500000
  65. char src[MAX_AT_ONCE], dst[MAX_AT_ONCE];
  66.  
  67. main(argc, argv)
  68.     int argc;
  69.     char **argv;
  70. {
  71.     register int *sizePtr;
  72.     struct rusage begin, end;
  73.     struct timeval start, stop;
  74.     int micros, totalBytes, bytesSoFar, count;
  75.     double mbSec;
  76.  
  77.     if (argc > 1) {
  78.     totalBytes = 1000000*atoi(argv[1]);
  79.     } else {
  80.     totalBytes = 5000000;
  81.     }
  82.  
  83.     for (sizePtr = sizes; *sizePtr > 0; sizePtr++) {
  84. #ifdef GETRUSAGE
  85.     getrusage(RUSAGE_SELF, &begin);
  86. #else
  87.     gettimeofday(&start, (struct timezone *) NULL);
  88. #endif
  89.  
  90.     for (bytesSoFar = 0; bytesSoFar < totalBytes;
  91.         bytesSoFar += count) {
  92.         count = totalBytes - bytesSoFar;
  93.         if (count > *sizePtr) {
  94.         count = *sizePtr;
  95.         }
  96.         bcopy(src, dst, count);
  97.     }
  98. #ifdef GETRUSAGE
  99.     getrusage(RUSAGE_SELF, &end);
  100.     micros = (end.ru_utime.tv_sec
  101.         - begin.ru_utime.tv_sec)*1000000
  102.         + (end.ru_utime.tv_usec - begin.ru_utime.tv_usec);
  103. #else
  104.     gettimeofday(&stop, (struct timezone *) NULL);
  105.     micros = 1000000*(stop.tv_sec - start.tv_sec)
  106.         + stop.tv_usec - start.tv_usec;
  107. #endif
  108.  
  109.     mbSec = totalBytes;
  110.     mbSec /= micros;
  111.     printf("Transfer size: %d, Mbytes/sec: %.2f\n", *sizePtr,
  112.         mbSec);
  113.     }
  114. }
  115. @
  116.  
  117.  
  118. 1.1
  119. log
  120. @Initial revision
  121. @
  122. text
  123. @d22 1
  124. a22 1
  125. static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.2 89/01/07 04:12:18 rab Exp $ SPRITE (Berkeley)";
  126. d34 1
  127. a34 1
  128.     {10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, -1};
  129. @
  130.